import { getProductAttrList } from '@/api/product'
import { ref } from 'vue'

export default function () {
  const productAttrList = ref<ProductAttrType[]>([])
  const productAttrCount = ref(0)
  const isLoadingAttrList = ref(false)

  function handleGetProductAttrList(params = {}) {
    isLoadingAttrList.value = true
    getProductAttrList(params)
      .then(res => {
        productAttrList.value = res.list
        productAttrCount.value = res.count
      })
      .finally(() => {
        isLoadingAttrList.value = false
      })
  }

  return {
    handleGetProductAttrList,
    productAttrList,
    productAttrCount,
    isLoadingAttrList,
  }
}
